import { createTransport } from "nodemailer"

const transporter = createTransport({
    service: 'qq',
    port: 465,    // SMTP 端口
    auth: {
        user: "your-qq@qq.com",
        // pass: "dkgbqnfmnfddgedd"
        pass: process.env.SMTP_CODE
    },
});
console.log(process.env.SMTP_CODE)
export const sendMailCode = (
    email: string,
    code: string
) => {
    const mailOptions = {
        from: "your-qq@qq.com", // 发件人地址
        to: email, // 收件人地址
        subject: "hello!", // 邮件主题
        text: code // 邮件内容
    };
    return new Promise((resolve, rejects) => {
        transporter.sendMail(mailOptions, (error, info) => {
            if (!!error) return rejects(error)
            resolve(info)
        })
    })
}
